home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7382 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP! Please! Why doesn't this work
  5. Date: 25 Feb 1996 19:38:02 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4gqvda$ish@umbc9.umbc.edu>
  8. References: <Pine.ULT.3.91a.960215131933.614A-100000@red5.cac.washington.edu> <GEORG.96Feb23192440@acds14.physik.rwth-aachen.de>
  9. NNTP-Posting-Host: umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. >>...
  13. >>     solution_array = (char **) malloc(size);   
  14.  
  15. >       This should read 
  16. >         solution_array = (char**)malloc(size * sizof(char*));
  17.  
  18. Actually I'd write:
  19.  
  20. solution_array = malloc (size * sizeof (*solution_array));
  21.  
  22. Plus I would make sure that I have supplied the <stdlib.h> library.
  23. This has the advantage of being correct, not having any typos (I hope),
  24. not relying on possibly changing data types, and not hiding possible
  25. errors with unnecessary casts.
  26. -- 
  27. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  28.  
  29. Jonas J. Schlein  (schlein@gl.umbc.edu)
  30.